﻿#include "GUIDialogBase.h"
#include "GUIDialogManager.h"

#include "PickDataProvider/PickedData.h"
#include "OperatorsInterface/GraphEventOperator.h"

#include "FITK_Kernel/FITKCore/FITKOperatorRepo.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Component/FITKAcousticsModel/FITKAcousticsDiscModel.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsPhysics.h"

namespace GUI
{
    GUIDialogBase::GUIDialogBase(QWidget* parent) :
        Core::FITKDialog(parent)
    {
        setAttribute(Qt::WidgetAttribute::WA_DeleteOnClose);
        GUIDialogManager::getInstance()->dialogCreated(this, this->objectName());
        //获取离散数据
        _DiscModel = FITKAPP->getGlobalData()->getMeshData<Acoustics::FITKAcousticsDiscModel>();
        _physics = FITKAPP->getGlobalData()->getPhysicsData<Acoustics::FITKAcousticsPhysics>();
        if (_DiscModel == nullptr)return;
        _SEAModel = _DiscModel->getSEAModel();
        _FEModel = _DiscModel->getFEModel();
    }

    GUIDialogBase::~GUIDialogBase()
    {
        // 通知管理器对话框已销毁
        GUIDialogManager::getInstance()->dialogDestoried(this);
    }

    void GUIDialogBase::hightGraphObj(const int& objID)
    {
        EventOper::GraphEventOperator* operGraph = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
        if (operGraph) {
            operGraph->hightGraphObj(objID);
        }
    }

    void GUIDialogBase::disHightGraphObj(const int & objID)
    {
        EventOper::GraphEventOperator* operGraph = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
        if (operGraph) {
            operGraph->disHightGraphObj(objID);
        }
    }

    void GUIDialogBase::clearAllHightGraph()
    {
        EventOper::GraphEventOperator* operGraph = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
        if (operGraph) {
            operGraph->clearAllHightGraph();
        }
    }
}